/**
 * 二叉树节点
 */
function TreeNode(val = 0, left = null, right = null) {
    this.val = val;
    this.left = left;
    this.right = right;
}

/**
 * 从数组生成二叉树
 */
function makeBinaryTree(arr) {
    const len = arr.length;
    const createNode = (i) => {
        if (i < len && arr[i] !== null) {
            return new TreeNode(
                arr[i],
                createNode(2 * i + 1),
                createNode(2 * i + 2)
            );
        }
        return null;
    };

    return createNode(0);
}
